package com.gxa.web_admin.controller.kk;
import com.google.common.collect.Lists;
import java.util.Date;

import com.gxa.common.base.RespResult;
import com.gxa.modules.dto.AnnouncementDTO;
import com.gxa.modules.entity.CrmAnnouncement;
import com.gxa.modules.service.AnnouncementService;
import com.gxa.web_admin.vo.AnnouncementVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 公告
 *
 * @author kk
 * @date 2023/03/27
 */
@RestController
@RequestMapping("/announcement")
public class AnnouncementController {
    @Autowired
    private AnnouncementService announcementService;

    //显示公告列表
    @RequestMapping(value = "selectAllannouncement",method = RequestMethod.POST)

    public RespResult showAll(@RequestBody AnnouncementVo announcementVo){
        AnnouncementDTO announcementDTO = new AnnouncementDTO();
        announcementDTO.setCurrentPage(announcementVo.getCurrentPage());
        announcementDTO.setPageSize(announcementVo.getPageSize());
        announcementDTO.setAnnouncementType(announcementVo.getAnnouncementType());
        announcementDTO.setAnnouncementContent(announcementVo.getAnnouncementContent());
        announcementDTO.setAnnouncementTitle(announcementVo.getAnnouncementTitle());
        announcementDTO.setEmployeeId(announcementVo.getEmployeeId());
        announcementDTO.setAnnouncementTime(announcementVo.getAnnouncementTime());
        announcementDTO.setAnnouncementStatus(announcementVo.getAnnouncementStatus());
        announcementDTO.setAppendixUrl(announcementVo.getAppendixUrl());
        List<CrmAnnouncement> result=announcementService.showAll(announcementDTO);
        return RespResult.success(result);
    }

    //添加公告
    @RequestMapping(value = "addannouncement",method = RequestMethod.POST)

    public RespResult addAnnouncement(@RequestBody CrmAnnouncement crmAnnouncement){

            int result=announcementService.addAnnouncement(crmAnnouncement);
        return RespResult.success(result);

    }


    //修改公告
    @RequestMapping(value = "updateannouncement",method = RequestMethod.POST)

    public RespResult updateannouncement(@RequestBody CrmAnnouncement crmAnnouncement){

        int result=announcementService.updateannouncement(crmAnnouncement);
        return RespResult.success(result);

    }


    //删除公告
    @RequestMapping(value = "deleteannouncement",method = RequestMethod.POST)

    public RespResult deleteannouncement(Integer id){

        int result=announcementService.deleteannouncement(id);
        return RespResult.success(result);

    }

}
